package com.itheima.a01staticdemo03;

import java.util.ArrayList;
import java.util.List;

public class Studentutil {
    private Studentutil() {

    }

    public static int getAgeMax(ArrayList<Student> list) {
        int max=list.get(0).getAge();//list.get(0)是集合的元素
        for (int i = 1; i < list.size(); i++) {
           //list.get(i)集合里的每一个元素 ,每个元素是一个学生对象,我们还需getAge获取到年龄之后再进行比较
            int tmpAge = list.get(i).getAge();
            if (tmpAge > max) {
                max = tmpAge;
            }
        }
        return max;
    }
}
